home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / csview / formdes.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-04-05  |  13.2 KB  |  386 lines

  1. VERSION 2.00
  2. Begin Form formdes 
  3.    BackColor       =   &H00FFFFFF&
  4.    Caption         =   "Automatically navigate thru pre-printed forms"
  5.    ClientHeight    =   6675
  6.    ClientLeft      =   345
  7.    ClientTop       =   330
  8.    ClientWidth     =   8655
  9.    Height          =   7080
  10.    Left            =   285
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   6675
  13.    ScaleWidth      =   8655
  14.    Top             =   -15
  15.    Width           =   8775
  16.    Begin CommandButton Command2 
  17.       BackColor       =   &H00C0C0C0&
  18.       Caption         =   "&Tip"
  19.       FontBold        =   0   'False
  20.       FontItalic      =   0   'False
  21.       FontName        =   "MS Sans Serif"
  22.       FontSize        =   8.25
  23.       FontStrikethru  =   0   'False
  24.       FontUnderline   =   0   'False
  25.       Height          =   360
  26.       Left            =   5835
  27.       TabIndex        =   12
  28.       Top             =   1740
  29.       Width           =   1290
  30.    End
  31.    Begin CommandButton Command1 
  32.       BackColor       =   &H00C0C0C0&
  33.       Caption         =   "&Print"
  34.       FontBold        =   0   'False
  35.       FontItalic      =   0   'False
  36.       FontName        =   "MS Sans Serif"
  37.       FontSize        =   8.25
  38.       FontStrikethru  =   0   'False
  39.       FontUnderline   =   0   'False
  40.       Height          =   360
  41.       Left            =   7215
  42.       TabIndex        =   0
  43.       Top             =   1740
  44.       Width           =   1290
  45.    End
  46.    Begin vsViewPort vp 
  47.       BackColor       =   &H00404040&
  48.       ConvInfo        =   FORMDES.FRX:0000
  49.       Height          =   4290
  50.       Left            =   390
  51.       Top             =   2205
  52.       VirtualHeight   =   11100
  53.       VirtualWidth    =   8600
  54.       Width           =   8145
  55.       Begin PictureBox picFax 
  56.          BackColor       =   &H00FFFFFF&
  57.          Height          =   11000
  58.          Left            =   60
  59.          Picture         =   FORMDES.FRX:000B
  60.          ScaleHeight     =   10965
  61.          ScaleWidth      =   8475
  62.          TabIndex        =   10
  63.          Top             =   105
  64.          Width           =   8500
  65.          Begin TextBox txtFax 
  66.             BackColor       =   &H00FFFFFF&
  67.             FontBold        =   0   'False
  68.             FontItalic      =   0   'False
  69.             FontName        =   "Arial"
  70.             FontSize        =   8.25
  71.             FontStrikethru  =   0   'False
  72.             FontUnderline   =   0   'False
  73.             ForeColor       =   &H00000000&
  74.             Height          =   315
  75.             Index           =   0
  76.             Left            =   4500
  77.             TabIndex        =   1
  78.             Text            =   "01/01/01"
  79.             Top             =   315
  80.             Width           =   3000
  81.          End
  82.          Begin TextBox txtFax 
  83.             BackColor       =   &H00FFFFFF&
  84.             FontBold        =   0   'False
  85.             FontItalic      =   0   'False
  86.             FontName        =   "Arial"
  87.             FontSize        =   8.25
  88.             FontStrikethru  =   0   'False
  89.             FontUnderline   =   0   'False
  90.             ForeColor       =   &H00000000&
  91.             Height          =   315
  92.             Index           =   5
  93.             Left            =   4500
  94.             TabIndex        =   6
  95.             Text            =   "Your name goes here"
  96.             Top             =   3735
  97.             Width           =   3000
  98.          End
  99.          Begin TextBox txtFax 
  100.             BackColor       =   &H00FFFFFF&
  101.             FontBold        =   0   'False
  102.             FontItalic      =   0   'False
  103.             FontName        =   "Courier New"
  104.             FontSize        =   8.25
  105.             FontStrikethru  =   0   'False
  106.             FontUnderline   =   0   'False
  107.             ForeColor       =   &H00000000&
  108.             Height          =   315
  109.             Index           =   6
  110.             Left            =   4485
  111.             TabIndex        =   7
  112.             Top             =   4425
  113.             Width           =   3000
  114.          End
  115.          Begin TextBox txtFax 
  116.             BackColor       =   &H00FFFFFF&
  117.             FontBold        =   0   'False
  118.             FontItalic      =   0   'False
  119.             FontName        =   "Courier New"
  120.             FontSize        =   8.25
  121.             FontStrikethru  =   0   'False
  122.             FontUnderline   =   0   'False
  123.             ForeColor       =   &H00000000&
  124.             Height          =   315
  125.             Index           =   7
  126.             Left            =   4500
  127.             TabIndex        =   8
  128.             Text            =   "1"
  129.             Top             =   5070
  130.             Width           =   3000
  131.          End
  132.          Begin TextBox txtFax 
  133.             BackColor       =   &H0000FFFF&
  134.             FontBold        =   0   'False
  135.             FontItalic      =   0   'False
  136.             FontName        =   "Courier New"
  137.             FontSize        =   8.25
  138.             FontStrikethru  =   0   'False
  139.             FontUnderline   =   0   'False
  140.             ForeColor       =   &H00000000&
  141.             Height          =   3255
  142.             Index           =   8
  143.             Left            =   405
  144.             MultiLine       =   -1  'True
  145.             TabIndex        =   9
  146.             Top             =   6435
  147.             Width           =   7575
  148.          End
  149.          Begin ComboBox cmbFax 
  150.             BackColor       =   &H00FFFFFF&
  151.             FontBold        =   0   'False
  152.             FontItalic      =   0   'False
  153.             FontName        =   "Arial"
  154.             FontSize        =   8.25
  155.             FontStrikethru  =   0   'False
  156.             FontUnderline   =   0   'False
  157.             Height          =   315
  158.             Index           =   0
  159.             Left            =   4500
  160.             TabIndex        =   2
  161.             Top             =   1005
  162.             Width           =   3000
  163.          End
  164.          Begin ComboBox cmbFax 
  165.             BackColor       =   &H00FFFFFF&
  166.             FontBold        =   0   'False
  167.             FontItalic      =   0   'False
  168.             FontName        =   "Arial"
  169.             FontSize        =   8.25
  170.             FontStrikethru  =   0   'False
  171.             FontUnderline   =   0   'False
  172.             Height          =   315
  173.             Index           =   1
  174.             Left            =   4500
  175.             TabIndex        =   3
  176.             Top             =   1680
  177.             Width           =   3000
  178.          End
  179.          Begin ComboBox cmbFax 
  180.             BackColor       =   &H00FFFFFF&
  181.             FontBold        =   0   'False
  182.             FontItalic      =   0   'False
  183.             FontName        =   "Arial"
  184.             FontSize        =   8.25
  185.             FontStrikethru  =   0   'False
  186.             FontUnderline   =   0   'False
  187.             Height          =   315
  188.             Index           =   2
  189.             Left            =   4500
  190.             TabIndex        =   4
  191.             Top             =   2355
  192.             Width           =   3000
  193.          End
  194.          Begin ComboBox cmbFax 
  195.             BackColor       =   &H00FFFFFF&
  196.             FontBold        =   0   'False
  197.             FontItalic      =   0   'False
  198.             FontName        =   "Arial"
  199.             FontSize        =   8.25
  200.             FontStrikethru  =   0   'False
  201.             FontUnderline   =   0   'False
  202.             Height          =   315
  203.             Index           =   3
  204.             Left            =   4500
  205.             TabIndex        =   5
  206.             Top             =   3060
  207.             Width           =   3000
  208.          End
  209.       End
  210.    End
  211.    Begin vsPrinter prt 
  212.       ConvInfo        =   FORMDES.FRX:1141
  213.       FontName        =   "Times New Roman"
  214.       FontSize        =   11
  215.       HdrFontBold     =   -1  'True
  216.       HdrFontName     =   "Courier New"
  217.       HdrFontSize     =   14
  218.       Height          =   300
  219.       Left            =   7425
  220.       PageBorder      =   0  'None
  221.       TableSep        =   "|;"
  222.       Top             =   495
  223.       Visible         =   0   'False
  224.       Width           =   1005
  225.    End
  226.    Begin Image Image1 
  227.       Height          =   975
  228.       Left            =   150
  229.       Picture         =   FORMDES.FRX:114C
  230.       Top             =   135
  231.       Width           =   6585
  232.    End
  233.    Begin Label Label1 
  234.       BackStyle       =   0  'Transparent
  235.       Caption         =   "Scan your forms and use standard VB controls on top of them"
  236.       FontBold        =   -1  'True
  237.       FontItalic      =   0   'False
  238.       FontName        =   "Arial"
  239.       FontSize        =   12
  240.       FontStrikethru  =   0   'False
  241.       FontUnderline   =   0   'False
  242.       Height          =   300
  243.       Left            =   180
  244.       TabIndex        =   11
  245.       Top             =   1125
  246.       Width           =   7305
  247.    End
  248. Option Explicit
  249. Sub cmbFax_Click (index As Integer)
  250.     Dim i%
  251.     Static changing%
  252.     If changing Then Exit Sub
  253.     changing = True
  254.     For i = 0 To 3
  255.     If i <> index Then cmbFax(i).ListIndex = cmbFax(index).ListIndex
  256.     Next
  257.     changing = False
  258. End Sub
  259. Sub cmbFax_GotFocus (index As Integer)
  260.     ShowMe cmbFax(index)
  261. End Sub
  262. Sub Command1_Click ()
  263.     Dim i%
  264.     Dim ml, mr, mt, mb
  265.     Dim x, y, w
  266.     Dim pw, ph
  267.     ' prepare printer
  268.     prt.Action = 3
  269.     ml = prt.MarginLeft
  270.     mr = prt.MarginRight
  271.     mt = prt.MarginTop
  272.     mb = prt.MarginBottom
  273.     pw = prt.PageWidth - ml - mr
  274.     ph = prt.PageHeight - mt - mb
  275.     ' draw form
  276.     prt.X1 = ml
  277.     prt.X2 = prt.PageWidth - mr
  278.     prt.Y1 = mt
  279.     prt.Y2 = prt.PageHeight - mb
  280.     prt.Picture = picfax.Picture
  281.     ' draw each control
  282.     prt.MarginBottom = -prt.PageHeight
  283.     On Error Resume Next
  284.     For i = 0 To controls.Count - 1
  285.           
  286.     ' adjust font
  287.     prt.FontName = controls(i).FontName
  288.     prt.FontBold = controls(i).FontBold
  289.     prt.FontItalic = controls(i).FontItalic
  290.     FontSize = controls(i).FontSize
  291.     prt.FontSize = TextHeight("Hj") * ph / picfax.Height / 20
  292.     ' adjust position
  293.     x = ml + controls(i).Left * pw / picfax.Width
  294.     y = mt + controls(i).Top * ph / picfax.Height
  295.     w = controls(i).Width * pw / picfax.Width
  296.     prt.MarginLeft = x
  297.     prt.MarginRight = (pw + ml + mr) - x - w
  298.     prt.MarginTop = y
  299.     prt.CurrentX = prt.MarginLeft
  300.     prt.CurrentY = prt.MarginTop
  301.     prt = controls(i).Text
  302.     Next i
  303.     On Error GoTo 0
  304.     ' all done
  305.     prt.Action = 6
  306.     prt.MarginLeft = ml
  307.     prt.MarginRight = mr
  308.     prt.MarginTop = mt
  309.     prt.MarginBottom = mb
  310. End Sub
  311. Sub Command2_Click ()
  312.     MsgBox "This demo also shows you how to automatically scroll the form with the keyboard.  Just click on a field and press the TAB key."
  313. End Sub
  314. Sub Form_Load ()
  315.     Dim i%
  316. ' this is a simple form-fill/print/preview application.
  317. ' the form is drawn in Visio, or Corel, or Excel, and saved
  318. ' as a metafile.
  319. ' the metafile is placed in a picture box, along with text
  320. ' and combo box controls. the controls go in the proper
  321. ' position to be filled out.
  322. ' the whole thing goes into a viewport. there's a routine
  323. ' that ensures the control with the focus is always visible for
  324. ' data entry. or the user can scroll with the viewport.
  325. ' to print, the vsprinter copies  the form picture and then
  326. ' traverses the controls. if they are text or combo boxes they
  327. ' get printed at the proper position, with the proper font.
  328. ' this is a cool way to create smart forms with fields that
  329. ' depend on other fields etc. for example, a 1040, fax, travel
  330. ' expense report etc.
  331.     txtFax(0) = Format$(Date$, "mmmm dd, yyyy")
  332.     cmbFax(0).AddItem "Gustavo Eydelsteyn"
  333.     cmbFax(1).AddItem "Videosoft"
  334.     cmbFax(2).AddItem "(510) 843-0174"
  335.     cmbFax(3).AddItem "(510) 704-8200"
  336.     cmbFax(0).AddItem "Bill Gates"
  337.     cmbFax(1).AddItem "Microsoft"
  338.     cmbFax(2).AddItem "(206) 555-1000"
  339.     cmbFax(3).AddItem "(206) 555-2000"
  340.     cmbFax(0).AddItem "Phil Kahn"
  341.     cmbFax(1).AddItem "Starfish"
  342.     cmbFax(2).AddItem "(444) 555-1000"
  343.     cmbFax(3).AddItem "(444) 555-2000"
  344.     cmbFax(0).AddItem "Ray Noorda"
  345.     cmbFax(1).AddItem "Novell"
  346.     cmbFax(2).AddItem "(555) 555-1000"
  347.     cmbFax(3).AddItem "(555) 555-2000"
  348.     cmbFax(0).AddItem "Jim Manzi"
  349.     cmbFax(1).AddItem "Lotus"
  350.     cmbFax(2).AddItem "(666) 555-1000"
  351.     cmbFax(3).AddItem "(666) 555-2000"
  352.     cmbFax(0).AddItem "Lee Iacocca"
  353.     cmbFax(1).AddItem "Chrysler"
  354.     cmbFax(2).AddItem "(777) 555-1000"
  355.     cmbFax(3).AddItem "(777) 555-2000"
  356. End Sub
  357. Sub Form_Resize ()
  358.     vp.Width = scalewidth - vp.Left * 2
  359.     vp.Height = scaleheight - vp.Top - vp.Left
  360. End Sub
  361. Sub ShowMe (c As Control)
  362.     Dim v%, offset%
  363.     offset = 400
  364.     ' show right
  365.     v = c.Left + c.Width + offset
  366.     If v > vp.VirtualLeft + vp.Width Then vp.VirtualLeft = v - vp.Width
  367.     ' show start
  368.     v = c.Left - c.Width
  369.     If v < vp.VirtualLeft Then vp.VirtualLeft = v
  370.     ' show bottom
  371.     v = c.Top + c.Height + offset
  372.     If v > vp.VirtualTop + vp.Height Then vp.VirtualTop = v - vp.Height
  373.     ' show top
  374.     v = c.Top - offset
  375.     If v < vp.VirtualTop Then vp.VirtualTop = v
  376. End Sub
  377. Sub txtFax_GotFocus (index As Integer)
  378.     txtFax(index).SelStart = 0
  379.     txtFax(index).SelLength = 1000
  380.     ShowMe txtFax(index)
  381. End Sub
  382. Sub vp_Scroll ()
  383.   ' to avoid drop combo to float
  384.   Me.SetFocus
  385. End Sub
  386.